<link rel="stylesheet" type="text/css" href="{{ URL::asset('public_css/base.css') }}" />
@include('new.newheader')
<link rel="stylesheet" type="text/css" href="{{ URL::asset('newpay/css/newpay.css') }}" />

<div class="J_pay">
	<p>
		EAI2.0 &nbsp; 大数据智能跟单系统
	</p>
</div>

<div class="J_pay_content">
	<!-- <div class="J_productImg">
		<img src="{{ URL::asset('newpay/image/chanping.jpg') }}" alt="">
	</div> -->
	<div class="J_pay_text">
		<div class="J_pay_title">
			<h1>EAI2.0 &nbsp; 大数据智能跟单系统</h1>
			<p>EAI2.0 &nbsp; 智能跟单系统  &nbsp;&nbsp;让投资变的更简单，让交易变得更智能</p>
		</div>
		<div class="J_pay_banben clearfloat">
			<h2>选择版本</h2>
			<div class="J_pay_price" onclick="selectMess(this)">
				<p>EAI2.0</p>
				<p>大数据智能跟单系统</p>
				<p>
					<span class="J_mon"><span class="cpMonth">3</span>个月</span>
					<span class="J_money">￥8997</span>
				</p>
			</div>
			<div class="J_pay_price J_pay_margin" onclick="selectMess(this)">
				<p>EAI2.0</p>
				<p>大数据智能跟单系统</p>
				<p>
					<span class="J_mon"><span class="cpMonth">6</span>个月</span>
					<span class="J_money">￥17994</span>
				</p>
			</div>
			<div class="J_pay_price J_pay_top" onclick="selectMess(this)">
				<p>EAI2.0</p>
				<p>大数据智能跟单系统</p>
				<p>
					<span class="J_mon"><span class="cpMonth">12</span>个月</span>
					<span class="J_money">￥35988</span>
				</p>
			</div>
		</div>
		<div class="J_banlv">
			<h2>选择伴侣<span>（可选建议购买）</span><i id="J_vps" onclick="vpsSelect(this)"></i><span class="aloneBuy" onclick="aloneBuy();">单独购买</span></h2>
			<p>EAI2.0 &nbsp; 大数据智能跟单系统伴侣 &nbsp; <span>￥200/月</span></p>
		</div>
		<div class="J_dingdan">
			<div class="J_dingdan_list" id="J_dingdan_list" style="display: none;">
				<img src="{{ URL::asset('newpay/image/minchangping.png') }}" alt="">
				<span>EAI2.0 &nbsp; 大数据智能跟单系统 &nbsp; <b id="J_listmon">6个月</b> <span id="J_listmoney">￥8997</span></span>
			</div>
			<div style="height: 8px;"></div>
			<div class="J_dingdan_list" id="J_dingdan_vps" style="display: none;">
				<img src="{{ URL::asset('newpay/image/min_qinglv.png') }}" alt="">
				<span>EAI2.0 &nbsp; 大数据智能跟单系统伴侣 &nbsp; <b id="J_vpsmon">6个月</b> <span id="J_vpsmoney">￥1200</span></span>
			</div>
		</div>
		<div class="J_yanzhengma">
			<div>
				优惠码：<input type="text" placeholder="请输入优惠码" id="yhInput">
				<span onclick="yhCount()" id="yhbtn">验证</span>
			</div>
			<p id="msg" style="display: none;">验证成功<img src="{{ URL::asset('newpay/image/success.png') }}" alt=""></p>
		</div>
		<div class="J_jiesuan">
			<p>优惠金额 <span id="yhVps">￥0.00</span></p>
			<p>快递     <span><s>￥20.00</s>￥0.00</span></p>
		</div>
		<div class="J_zongji">
			<p id="J_count">
				<span>总计</span>
				￥0.00
				<s>￥0.00</s>
			</p>
		</div>
		<div class="J_tijiao" onclick="subBtn()">
			提交
		</div>
	</div>
	<div style="clear: both;height: 180px;"></div>
</div>
<div id="mask"></div>
<div id="tanCeng">
	<span></span>
	<a href='/authenticate?id=tiyan' style='cursor:pointer;color:#3b9ce0;'>
		<button onclick="perfectInfo()" style="display:none;">完善资料</button>
	</a>
</div>
<!-- 单独购买弹层 -->
<div class="alonebuy_popups">
	<div class="main">
		<div class="t">
			选择时间
		</div>
		<div class="choose">
			<div onclick="chooseMonth(this);">
				<p class="month">3个月</p>
				<p>¥<span class="money">600</span></p>
			</div>
			<div onclick="chooseMonth(this);">
				<p class="month">6个月</p>
				<p>¥<span class="money">1200</span></p>
			</div>
			<div onclick="chooseMonth(this);">
				<p class="month">12个月</p>
				<p>¥<span class="money">2400</span></p>
			</div>
		</div>
		<div class="email">
			<span>邮箱确认</span>
			<span>(购买后请您留意邮箱)</span>
		</div>
		<div class="line"></div>
		<div class="email_input">
			<input type="text" value="{{$email}}">
			<span>如果邮箱有误请直接填写正确的邮箱</span>
		</div>
		<div class="totle">
			<span>总计</span>
			<span>¥&nbsp;<span class="money">000</span></span>
		</div>
                <div class="zhifuimg">
                    <input type="radio" value="1" name="paytype" checked="checked">
                    <span>
                            <img src="http://local.eajyq.com/newpay/image/event-alipay.png" alt="">
                    </span>
                    <input type="radio" value="0" name="paytype">
                    <span>
                            <img src="http://local.eajyq.com/newpay/image/weixinpay.png" alt="">
                    </span>
		</div>
		<div class="btn" onclick="subBtn2(this);">
			提交
		</div>
	</div>
	<div class="close" onclick="close_popups();">
		<img src="{{URL::asset('images/close.png')}}" alt="">
	</div>
</div>
<div id="tanCeng">
	<span></span>
	<a href='/authenticate?id=tiyan' style='cursor:pointer;color:#3b9ce0;'>
		<button onclick="perfectInfo()" style="display:none;">完善资料</button>
	</a>
</div>
<div id="mask"></div>
<div class="zhifutan">
	<div class="zhifutitle">
		<span>收款方：毅思科技</span>
		<span class="J_close"><img style="margin-top: 18px;" src="{{URL::asset('images/close.png')}}"></span>
	</div>
	<div class="J_conTitle">
		<span>支付宝扫一扫</span>
		<div class="erweima">
			<img src="{{ URL::asset('newpay/image/erweima.png') }}" alt="">
		</div>
	</div>
</div>

<script src="{{ URL::asset('public_js/jquery-3.2.1.min.js') }}"></script>
<script>
var clearpay='';
function checkLogin(){
	var islogin = "<?php echo Session('eai')['tel']?>";
	if(!islogin){
		//layer.msg('请先<a href="{{ url('/login') }}">登录</a>！');
		showCeng();
		$('#tanCeng>a>button').hide();
		$("#tanCeng").css({'width':'250px','height':'80px','line-height':'80px'}).html('请先<a href="{{ url('/login') }}" style="cursor:pointer;color:#3b9ce0;font-size: 20px;">登录</a>！');
		return false;
	}
}
function showCeng(){
	var div_mask=$('#mask');
	var width=document.body.scrollWidth+'px';
	var height=document.body.scrollHeight+'px';
	div_mask.css({'width':width,'height':height,'display':'block'});
	$('#mask').show();
	$("#tanCeng").show();
}
var isYH = false;
// 选择EAI只能系统月份与产品
function selectMess(obj){
	checkLogin();
	var month = $(obj).find($('.cpMonth')).text(),   // 月份
		money = $(obj).find($('.J_money')).text(); // 钱
	$(obj).addClass('J_active').siblings().removeClass('J_active');
	$('#J_dingdan_list').show();   // 产品的盒子显示
	$('#J_listmon').text(month+'个月');   //  产品盒子的月份
	$('#J_listmoney').text(money); // 产品盒子的钱
	$('#J_vpsmon').text(month+'个月');    // VPS的月份
	$('#J_vpsmoney').text('￥'+(Number(month)*200))  // VPS的金钱就是6000
	publicCount(money,month)
};
// 计算优惠码
function yhCount(){
	var str = 'EAI8888';
	var yhInput = $('#yhInput').val();
	var yhChPin = $('.J_active').find('.cpMonth').text();//选中的月份
	if(yhInput != str){
		isYH = false;
		var money = $('.J_active').find('.J_money').text();
		publicCount(money,yhChPin);
		layer.msg('您输入优惠错误，请重新输入');
		$('#msg').hide();
	}else{
		$('#yhInput').attr('disabled','disabled');
		$('#yhbtn').removeAttr('onclick');
		$('#msg').show();
		var JzjCount     = $('#zjCount').text();//总计
		var isYHTwoMonth = Number(yhChPin) == 12?0:0;//购买12个月优惠两个月
		yhChPin          = yhChPin == 12?(yhChPin):yhChPin;//如果是12个优惠按10个月算
		var jisuanYh  	 = (500*Number(yhChPin));//按月优惠金额
		$('#zjCount').text(JzjCount-jisuanYh) // 总计的金额 由于公共方法的总计里已经优惠了两个月 这里不需要再减去
		jisuanYh = jisuanYh+isYHTwoMonth;//总共优惠金额
		$('#yhVps').text("￥"+(jisuanYh))  // 优惠金额
		isYH = true;
	}
}
// 公共的总计方法
function publicCount(money,selectMonth){
	var vpsMoney = $('#J_vpsmoney').text();
	var numMoney = Number(money.substr(1));   // 产品的金额J_listmoney  J_vpsmoney
	var numVps   = Number(vpsMoney.substr(1));   // 情侣Vps的金额
	var J_vpsPrice = $('#J_vps').text();
	var yhMonje = 0;
	var isYHTwoMonth = 0;
	yhMonje =  isYH ?selectMonth*500:yhMonje;
	if(isYH){
		isYHTwoMonth = selectMonth == 12?0:0;//购买12个月优惠两个月
	}else{
		isYHTwoMonth = selectMonth == 12?0:0;//购买12个月优惠两个月
	}
	yhMonje = yhMonje+isYHTwoMonth;//总共优惠金额
	$('#yhVps').text("￥"+(yhMonje))  // 优惠金额
	if(J_vpsPrice == ''){
		$('#J_count').html('<span>总计</span><span style="font-size:23px;" id="zjCount">'+(numMoney-yhMonje)+'</span><s>￥'+(numMoney)+'</s>')  //总计
	}else{
		$('#J_count').html('<span>总计</span><span style="font-size: 23px;" id="zjCount">'+(numMoney+numVps-yhMonje)+'</span><s>￥'+(numMoney+numVps)+'</s>')  //总计
	}

}
// 选择伴侣
function vpsSelect(obj){
	var vps = $(obj).text(),     // 选中状态
		vpsMon = $('.J_active').find('.cpMonth').text();
		if($(".J_pay_price").hasClass('J_active') == true){
			var money = $('.J_active').find('.J_money').text();
			if(vps == ''){
				$(obj).text('√');
				$('#J_dingdan_vps').show();
				$('#J_vpsmoney').text('￥'+(Number(vpsMon)*200)); // VPS的金钱就是6000
				$('#J_vpsmon').text(vpsMon+'个月');
			}else{
				$('#J_dingdan_vps').hide();
				$(obj).text('');
				$('#J_vpsmoney').text('￥0.00');
				$('#J_vpsmon').text('0个月');
			}
			publicCount(money,vpsMon);
			return false;
		}else{
			layer.msg('请选择大数据智能跟单系统');
			return false;
		}
};
//提交
function subBtn() {
	checkLogin();
	var yhMonth = $('.J_active').find('.cpMonth').text();//选中的月份
	var isbuyvps = $('#J_vps').text();
	if(isbuyvps != ''){
		isbuyvps = 1;
	}else{
		isbuyvps = 0;
	}
	var aisyh = isYH ?1:0;
	if(!yhMonth){
		layer.msg('请选择大数据智能跟单系统');
		return false;
	}
	window.location.href = '{{url("/paytwo?a=")}}'+aisyh+'&yhMonth='+yhMonth+'&isbuyvps='+isbuyvps;
}
// 单独购买
function aloneBuy(){
    var islogin = "<?php echo Session('eai')['tel']?>";
    if(!islogin){
            showCeng();
            $('#tanCeng>a>button').hide();
            $("#tanCeng").css({'width':'250px','height':'80px','line-height':'80px'}).html('请先<a href="{{ url('/login') }}" style="cursor:pointer;color:#3b9ce0;font-size: 20px;">登录</a>！');
            return false;
    }
    $('#mask').show();
    $('.alonebuy_popups').show();
}
// 选择月份
function chooseMonth(obj){
	$(obj).addClass('active').siblings('div').removeClass('active');
	var this_money = $(obj).find($('.money')).text(), // 获取选择的钱
		this_month = $(obj).find($('.month')).text(); // 选择的月份
	$('.totle').find($('.money')).text(this_money); // 将选择的钱赋值到总计
}

	//验证支付是否成功
function isPaySuccess(orderNo){
    if(orderNo==null){
        return false;
    }else{
        $.ajax({
                url:"checkpayresult", //验证支付是否成功
                type:'post',
                data:{'orderid':orderNo,'type':1},
                headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                dataType:'json',
                success:function(data){
                    if(data.type != -2){ //代表错误
                        if(data.status == 2){ //支付成功
                           layer.msg("支付成功");
                           clearInterval(clearpay);
                           window.location.href = '{{url("/")}}';
                        }else if(data.status == 3){
                            layer.msg('支付失败');
                            $(".zhifutan").hide();
                        }else if(data.status == 4){
                            layer.msg('订单失效，请重新购买');
                            $(".zhifutan").hide();
                        }
                    }else{
                        layer.msg('支付失败');
                        $(".zhifutan").hide();
                    }
                },
                error:function(xhr,textStatus){
//                    $('#mask').hide();
//                    $('.zf_msg').hide();
                    if(textStatus=='timeout'){
                            //处理超时的逻辑
                            $(obj).attr('onclick','subBtn2(this)');
                            layer.msg('网络超时请重新操作！');
                            return false;
                    }
                }
        });
    }
}

// vps付款按钮
function subBtn2(obj){
	var ddMoney = $('.choose > .active').find('.money').text(),//选中的钱
            ddMonth = $('.choose > .active').find('.month').text(),//选中的月份
            ddemail = $('.email_input > input').val(), // 获取邮箱
            ddtype  = $('input:radio:checked').val() // 获取vps支付方式
	if(!ddMoney || !ddMonth){
		layer.msg('请选择购买时间');
		return false;
	}
        if(!ddemail){
		layer.msg('请填写邮箱');
		return false;
	}
        if(!ddtype){
		layer.msg('请选择支付方式');
		return false;
	}
        $(obj).removeAttr('onclick');
        $.ajax({
            url:"{{url('/payvps')}}",
            type:'post',
            headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
            data:{'month':ddMonth,'money':ddMoney,'email':ddemail,'ddtype':ddtype},
            dataType:'json',
            success:function(data){
                if(data.status == 2){  // 成功以后跳转
                    $('#mask').show();
                    $('.zhifutan').show();
                    if(ddtype == 1){
                            $('.J_conTitle span').text('支付宝扫一扫');
                    }else{
                            $('.J_conTitle span').text('微信扫一扫');
                    }
                    $('.erweima img').attr('src',data.qrcode);
                    clearpay = setInterval(function () {
                            isPaySuccess(data.orderid);
                    },3000);
                    $(obj).attr('onclick','subBtn2(this)');
                }else if(data.status == 0){
                        layer.msg("请先<a href='{{ url("/login") }}' style='cursor:pointer;color:#3b9ce0;font-size: 20px;'>登录</a>！");
                        return false;
                }else{
                        $(obj).attr('onclick','subBtn2(this)');
                        layer.msg(data.msg);
                        return false;
                }
            }
        })
}
// 关闭单独购买弹窗
function close_popups(){
	$('#mask').hide();
	$('.alonebuy_popups').hide();
}
// 支付弹窗关闭
function zhifuclose(){
    $('.l_zhifutan').hide();
}

//提示层
function showCeng(){
        var div_mask=$('#mask');
        var width=document.body.scrollWidth+'px';
        var height=document.body.scrollHeight+'px';
        div_mask.css({'width':width,'height':height,'display':'block'});
        $('#mask').show();
        $("#tanCeng").show();
}

$('.J_close').click(function(){
        $('.zhifutan').hide();
});
</script>














